/*
 ============================================================================
 Name        : Klausur_ws_13_14_aufg3.c
 Author      : 
 Version     :
 Copyright   : Your copyright notice
 Description : Hello World in C, Ansi-style
 ============================================================================
 */

#include <stdio.h>
#include <stdlib.h>

typedef void* X;
typedef void* Y;

double add(X x, Y y) {
	//double *xx = (double *) x;
	//int *yy = *(int *) y;
	double z = 0;
	z = *(double*)x + *(int *) y;
	return z;

}

double mult(X x, Y y) {
	int *xx = (int *) x;
	int *yy = (int *) y;
	double z = 0;
	z = *xx * *yy;
	return z;
}

void map(int n, X x, size_t xx, Y y, size_t yy, double (*f)(X, Y)) {

	double ergebnis = 0;
	int i;
	int jx = (int) xx / n;
	int jy = (int) yy / n;

	for (i = 0; i < n; i++) {
		ergebnis += f(x, y);
		x += jx;
		y += jy;
}

	printf("\n" "ergebnis = %f", ergebnis);
}

int main(void) {

	double x[3] = { 1.0, 2.0, 3.0 };
	int y[3] = { 4, 5, 6 };


	printf("erste Element im Array y[0]= %d ", *y);
	size_t grosse_x = sizeof(x);
	size_t grosse_y = sizeof(y);
	int n = sizeof(x) / sizeof(x[0]);
	printf("\nn = %d", n);
	map(n, (double*)x, grosse_x, (int*)y, grosse_y, add);

	return 0;
}
